package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account  string `gorm:"type:varchar(30);comment:'账号'"`
	Password string `gorm:"type:char(32);comment:'密码'"`
	NickName string `gorm:"type:varchar(20);comment:'昵称'"`
}

func (u *User) GetUserByAccount() error {
	return DB.Where("account=?", u.Account).Limit(1).Find(&u).Error
}

func (u *User) Register() error {
	return DB.Create(&u).Error
}

type RealName struct {
	gorm.Model
	UserId   int64
	RealName string
	IdCard   string
}

func (r *RealName) GetRlByUserId() error {
	return DB.Where("userId=?", r.UserId).Limit(1).Find(&r).Error
}

func (r *RealName) Create() error {
	return DB.Create(&r).Error
}

type NateInfo struct {
	NateId   int64
	Title    string
	Context  string
	Tag      []string
	UserId   int64
	UserName string
}

type TAges struct {
	NateId int64
	Name   string
}

type ListNate struct {
	Nate
	UserId   int64
	UserName string
}
